- name: make the app be real
  hosts: os_control[0]:os_control_stg[0]
  user: root
  gather_facts: False

  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - "/srv/private/ansible/vars.yml"
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - role: openshift/project
    app: toddlers
    description: Small fedora-messaging toddlers that keep running around
    appowners:
    - pingou
    - abompard
    - mohanboddu
    - zlopez
    - scoady
    - asaleh
    tags:
      - appowners

  - role: rabbit/queue
    username: toddlers{{ env_suffix }}
    queue_name: toddlers{{ env_suffix }}
    routing_keys:
      # flag_ci_pr
      - "org.centos.*.ci.dist-git-pr.test.error"
      - "org.centos.*.ci.dist-git-pr.test.complete"
      - "org.centos.*.ci.dist-git-pr.test.running"
      # flag_commit_build
      - "org.fedoraproject.*.buildsys.build.state.change"
      # pdc_retired_packages
      - "org.fedoraproject.*.toddlers.trigger.pdc_retired_packages"
      - "org.fedoraproject.*.git.receive"
      # packager_bugzilla_sync
      - "org.fedoraproject.*.toddlers.trigger.packager_bugzilla_sync"
      # pdc_import_compose
      - "org.fedoraproject.*.toddlers.trigger.pdc_import_compose"
      - "org.fedoraproject.*.pungi.compose.status.change"
      # pdc_modules
      - "org.fedoraproject.*.mbs.module.state.change"
      # check_email_overrides
      - "org.fedoraproject.*.toddlers.trigger.check_email_overrides"
      # clean_retired_packages
      - "org.fedoraproject.*.toddlers.trigger.clean_retired_packages"
      # scm_request_processor
      - "org.fedoraproject.*.pagure.issue.new"
      - "org.fedoraproject.*.pagure.issue.edit"
      - "org.fedoraporject.*.pagure.issue.comment.added"
    thresholds:
      warning: 10
      critical: 100
    sent_topics: ^org\.fedoraproject\.{{ env_short }}\.toddlers\..*

  - role: openshift/keytab
    app: toddlers
    key: service.keytab
    secret_name: toddlers-keytab
    service: toddlers

  - role: openshift/ipa-client
    app: toddlers

  - role: openshift/object
    app: toddlers
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/secret-file
    app: toddlers
    secret_name: toddlers-fedora-messaging-key
    key: toddlers.key
    privatefile: "rabbitmq/{{env}}/pki/private/toddlers{{env_suffix}}.key"

  - role: openshift/secret-file
    app: toddlers
    secret_name: toddlers-fedora-messaging-crt
    key: toddlers.crt
    privatefile: "rabbitmq/{{env}}/pki/issued/toddlers{{env_suffix}}.crt"

  - role: openshift/secret-file
    app: toddlers
    secret_name: toddlers-fedora-messaging-ca
    key: toddlers.ca
    privatefile: "rabbitmq/{{env}}/pki/ca.crt"

  - role: openshift/object
    app: toddlers
    template: cron_playtime.yml
    objectname: cron_playtime.yml
    tags:
      - cron-job

  - role: openshift/object
    app: toddlers
    template: deploymentconfig.yml
    objectname: deploymentconfig.yml

  - role: openshift/object
    app: toddlers
    template: secret.yml
    objectname: secret.yml

  - role: openshift/object
    app: toddlers
    template: imagestream.yml
    objectname: imagestream.yml

  - role: openshift/start-build
    app: toddlers
    buildname: toddlers-build
    objectname: toddlers-build
